home *** CD-ROM | disk | FTP | other *** search
/ The Ring Press Kit / The Ring Press Kit.iso / mac / The Ring.dxr / trailer_2_QuickTime Control Button.ls < prev    next >
Encoding:
Text File  |  2002-09-24  |  3.6 KB  |  124 lines

  1. property pSprite, pActive, alertflag, pAction, pVideoSprite
  2.  
  3. on getBehaviorDescription
  4.   return "QT CONTROL BUTTON" & RETURN & RETURN & "Use this behavior to make almost any sprite into a control button for Quicktime video sprites. " & "Standard controls available through this behavior are Play, Stop/Pause, Rewind to beginning, Jump to End, Fast Forward (2x) and Fast backward (2x). " & "Drag behavior onto a sprite, select the Quicktime sprite to control, and which action the button will perform." & RETURN & RETURN & "PARAMETERS:" & RETURN & " - which Quicktime video sprite to control" & RETURN & " - Button action (rewind, stop, play, end, backward, forward)" & RETURN & RETURN & "PERMITTED TYPES:" & RETURN & " - Quicktime video to control" & RETURN & " - any graphics sprite(s) for the controls"
  5. end
  6.  
  7. on getBehaviorTooltip
  8.   return "Create custom QuickTime sprite video control buttons. " & "First place the QuickTime sprite on stage, then attach the behavior to the sprites that will serve as the controls."
  9. end
  10.  
  11. on beginSprite me
  12.   pAction = resolve(pAction)
  13.   mInitialize(me)
  14. end
  15.  
  16. on resolve prop
  17.   case prop of
  18.     pAction:
  19.       choiceslist = ["Rewind", "Stop", "Play", "End", "Backward", "Forward"]
  20.       lookup = [#rewind, #stop, #play, #end, #backward, #forward]
  21.   end case
  22.   return lookup[findPos(choiceslist, prop)]
  23. end
  24.  
  25. on mouseDown me
  26.   mVideoButton(me)
  27. end
  28.  
  29. on mouseUp me
  30.   case pAction of
  31.     #backward, #forward:
  32.       mVideoButton(me)
  33.   end case
  34. end
  35.  
  36. on mouseLeave me
  37.   case pAction of
  38.     #backward, #forward:
  39.       mVideoButton(me)
  40.   end case
  41. end
  42.  
  43. on mInitialize me
  44.   pSprite = sprite(me.spriteNum)
  45.   pActive = 0
  46. end
  47.  
  48. on mVideoButton me
  49.   if mVerifyVideo(pVideoSprite) then
  50.     case pAction of
  51.       #play:
  52.         sprite(pVideoSprite).movieRate = 1
  53.       #stop:
  54.         sprite(pVideoSprite).movieRate = 0
  55.       #rewind:
  56.         sprite(pVideoSprite).movieRate = 0
  57.         sprite(pVideoSprite).movieTime = 0
  58.       #end:
  59.         sprite(pVideoSprite).movieRate = 0
  60.         sprite(pVideoSprite).movieTime = sprite(pVideoSprite).member.duration
  61.       #backward:
  62.         if the mouseDown and rollover(me.spriteNum) then
  63.           pActive = 1
  64.           sprite(pVideoSprite).movieRate = -2
  65.         else
  66.           if pActive then
  67.             sprite(pVideoSprite).movieRate = 0
  68.           end if
  69.           pActive = 0
  70.         end if
  71.       #forward:
  72.         if the mouseDown and rollover(me.spriteNum) then
  73.           pActive = 1
  74.           sprite(pVideoSprite).movieRate = 2
  75.         else
  76.           if pActive then
  77.             sprite(pVideoSprite).movieRate = 0
  78.           end if
  79.           pActive = 0
  80.         end if
  81.     end case
  82.   end if
  83. end
  84.  
  85. on mVerifyVideo vSpriteNum
  86.   return sprite(vSpriteNum).member.type = #quickTimeMedia
  87. end
  88.  
  89. on mVideoSpriteList
  90.   vVideoList = []
  91.   repeat with i = 1 to the lastChannel
  92.     if mVerifyVideo(i) then
  93.       add(vVideoList, i)
  94.     end if
  95.   end repeat
  96.   return vVideoList
  97. end
  98.  
  99. on mErrorAlert me
  100.   if (the ticks - alertflag) > 10 then
  101.     alert("No video sprites are currently on the Stage.")
  102.     alertflag = the ticks
  103.   end if
  104. end
  105.  
  106. on isOKToAttach me, aSpriteType, aSpriteNum
  107.   return aSpriteType = #graphic
  108. end
  109.  
  110. on getPropertyDescriptionList me
  111.   if not (the currentSpriteNum) then
  112.     exit
  113.   end if
  114.   vVideos = mVideoSpriteList()
  115.   if not vVideos.count then
  116.     return mErrorAlert(me)
  117.   else
  118.     vPDList = [:]
  119.     setaProp(vPDList, #pVideoSprite, [#comment: "Video sprite channel", #format: #string, #default: vVideos[1], #range: vVideos])
  120.     setaProp(vPDList, #pAction, [#comment: "Video button action", #format: #string, #default: "Play", #range: ["Rewind", "Stop", "Play", "End", "Backward", "Forward"]])
  121.     return vPDList
  122.   end if
  123. end
  124.